using Autofac.Extensions.DependencyInjection;
using MDT.LifeSewagePlatform.Conmmon;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace MDT.LifeSewagePlatform.ServiceInstance
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string BasePath = AppDomain.CurrentDomain.BaseDirectory;
            var configuration = new ConfigurationBuilder()
               .SetBasePath(BasePath)
               .AddJsonFile(Path.Combine(BasePath, "appsettings.json"))
               .AddEnvironmentVariables()
               .Build();
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>();
                }).UseServiceProviderFactory(new AutofacServiceProviderFactory())
                .ConfigureLogging(loggerBuilder => {
                    loggerBuilder.AddLog4Net();
                }).
            UseWindowsService();
    }
}
